home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 24 / Amiga Format AFCD24 (Feb 1998, Issue 108).iso / -seriously_amiga- / shareware / programming / other / kaliosisquantrum / troll / kqgmtst.s.bak < prev    next >
Text File  |  1998-01-12  |  9KB  |  425 lines

  1. ;$Id
  2. ;fs "Includes"
  3.     incdir    "include:"
  4.     include   "Libraries/GadTools_lib.i"
  5.     include   "Libraries/GadTools.i"
  6.     include   "exec/exec_lib.i"
  7.     include   "exec/exec.i"
  8.     include   "exec/memory.i"
  9.     include   "devices/timer.i"
  10.     include   "dos/dos_lib.i"
  11.     include   "dos/dos.i"
  12.     include   "dos/dosextens.i"
  13.     include   "dos/dostags.i"
  14.     include   "intuition/intuition_lib.i"
  15.     include   "intuition/intuition.i"
  16.     include   "intuition/screens.i"
  17.     include   "graphics/graphics_lib.i"
  18.     include   "graphics/rastport.i"
  19.     include   "graphics/rpattr.i"
  20.     include   "graphics/text.i"
  21.     include   "graphics/layers_lib.i"
  22.  
  23. ;fe
  24. ;fs "Equates"
  25. exec_base EQU       4
  26. TRUE      EQU       -1
  27. FALSE     EQU       0
  28. MaxX      EQU       256
  29. MaxY      EQU       256
  30. MaxY2     EQU       65536
  31. K         EQU       512  ;2^9=512
  32.     mc68040
  33. ;fe
  34. ;fs "Variables"
  35.     rsreset
  36. StackPointer        rs.l      1
  37. PictWindowAddress   rs.l      1
  38. MappedWindowAddress rs.l      1
  39. PictWindowUserPort  rs.l      1
  40. PictRastPort        rs.l      1
  41. MappedRastPort      rs.l      1
  42. ScreenAddress       rs.l      1
  43. ScreenRastPort      rs.l      1
  44. WBarHeight          rs.b      1
  45. BorderTop           rs.b      1
  46. BorderLeft          rs.b      1
  47. LastMessage         rs.l      1
  48. Y                   rs.l      3
  49. Base                rs.l      1
  50. Inc                 rs.l      1
  51. SIZEOF_VARS         rs.b      0
  52. ;fe
  53. ;fs "Macros"
  54. Call      macro
  55.     IFGT      NARG-1
  56.     Move.l    \2_base,a6
  57.     ENDC
  58.     Jsr       _LVO\1(a6)
  59.     endm
  60.  
  61. OpenLib   macro     ;         OpenLib   name, rev, ?fail->
  62.     Bra       \1_next
  63.     IFND      \1_base
  64. \1_base:  Ds.l      1
  65.     ENDC
  66. \1_name:  Dc.b      "\1.library",0
  67.     Even
  68. \1_next:  Lea       \1_name(pc),a1
  69.     Moveq.l   \2,d0
  70.     Call      OpenLibrary,exec
  71.     Move.l    d0,\1_base
  72.     Beq       \3
  73.     endm
  74.  
  75. CloseLib  macro
  76.     Move.l    \1_base(pc),a1
  77.     Call      CloseLibrary,exec
  78.     endm
  79. ;fe
  80. ;fs "chaine de version"
  81. VERSION:  bra.s     Init
  82.     Dc.b      "$VER: Ground Mapper for Kaliosys Quantrum 0.1 (06/12/97) ©1997, CdBS (Troll)"
  83.     Even
  84. ;fe
  85. ;fs "Code"
  86. ;fs " Init"
  87. Init:
  88.     OpenLib   intuition,#39,LibError
  89.     OpenLib   dos,#39,LibError
  90.     OpenLib   gadtools,#39,LibError
  91.     OpenLib   graphics,#39,LibError
  92.     Call      OpenWorkBench,intuition
  93.     Move.l    d0,a0
  94.     Clr.l     d0
  95.     Move.b    sc_BarHeight(a0),d0
  96.     Move.b    d0,WBarHeight(a5)
  97.     Move.l    #SIZEOF_VARS,d0
  98.     Move.l    #MEMF_CLEAR,d1
  99.     Call      AllocVec,exec
  100.     Tst.l     d0
  101.     Beq       MemError
  102.     Move.l    d0,a5
  103.     Move.l    a7,StackPointer(a5)
  104. ;fe
  105. ;fs " OpenScreen"
  106. ;OpenScreen:
  107. ;          Sub.l     a0,a0
  108. ;          Lea       ScreenTagList,a1
  109. ;          Call      OpenScreenTagList,intuition
  110. ;          Move.l    d0,a1
  111. ;          Move.l    d0,ScreenAddress(a5)
  112. ;          Move.l    86(a1),d5
  113. ;          Move.l    d5,ScreenRastPort(a5)
  114. ;          Move.l    d0,Win1Scr
  115. ;          Move.l    d0,Win2Scr
  116. ;fe
  117. ;fs " Openwindows"
  118. OpenWindows:
  119.     Sub.l     a0,a0
  120.     Lea       PictWindowTagList,a1
  121.     Call      OpenWindowTagList,intuition
  122.     Tst.l     d0
  123.     Beq       Win1Error
  124.     Move.l    d0,a2
  125.     Move.l    d0,PictWindowAddress(a5)
  126.     Move.l    86(a2),d5
  127.     Move.l    d5,PictWindowUserPort(a5)
  128.     Move.l    50(a2),d5
  129.     Move.l    d5,PictRastPort(a5)
  130.     Move.b    54(a2),BorderTop(a5)
  131.     Move.b    55(a2),BorderLeft(a5)
  132.     Move.l    d5,a1
  133.     Move.l    #1,d0
  134.     Call      SetRast,graphics
  135.     bsr       _FillWin1
  136.     Sub.l     a0,a0
  137.     Lea       MappedWindowTagList,a1
  138.     Call      OpenWindowTagList,intuition
  139.     Tst.l     d0
  140.     Beq       Win2Error
  141.     Move.l    d0,a2
  142.     Move.l    d0,MappedWindowAddress(a5)
  143.     Move.l    50(a2),MappedRastPort(a5)
  144.     bsr       _MapWindow
  145. Loop:
  146.     bsr       Main
  147.     Bra       Loop
  148.  
  149. ;fe
  150. ;fs " Main"
  151. Main:
  152.     Movem.l   d0-7/a0-6,-(a7)
  153.     Move.l    PictWindowUserPort(a5),a0
  154.     Call      WaitPort,exec
  155.  
  156. EmptyPort:
  157.     Move.l    PictWindowUserPort(a5),a0
  158.     Call      GT_GetIMsg,gadtools
  159.     move.l    d0,LastMessage(a5)
  160.     Beq       Main
  161.     Move.l    d0,a3
  162.     Move.l    im_Class(a3),d0
  163.     Cmp.l     #IDCMP_CLOSEWINDOW,d0
  164.     Beq       CloseAll
  165.     Cmp.l     #IDCMP_RAWKEY,d0
  166.     Beq       CloseAll
  167.     Cmp.l     #IDCMP_REFRESHWINDOW,d0
  168.     Bne       ComeBack
  169.     Move.l    PictWindowAddress(a5),a0
  170.     Move.l    MappedWindowAddress(a5),a2
  171.     Bra       RefreshWin
  172. ComeBack:
  173.     Move.l    LastMessage(a5),a1
  174.     Call      GT_ReplyIMsg,gadtools
  175.     Movem.l   (a7)+,d0-7/a0-6
  176.     Rts
  177.  
  178.  
  179. RefreshWin:
  180.     Movem.l   d0/a0,-(a7)
  181.     Move.l    a0,d7
  182.     Call      GT_BeginRefresh,gadtools
  183.     Move.l    d7,a0
  184.     Move.l    #-1,d0
  185.     Call      GT_EndRefresh,gadtools
  186.     Move.l    a2,a0
  187.     Call      GT_BeginRefresh
  188.     Move.l    a2,a0
  189.     Move.l    #-1,d0
  190.     Call      GT_EndRefresh
  191.     Movem.l   (a7)+,d0/a0
  192.     Bra       Main
  193. ;fe
  194. ;fs " CloseAll"
  195. CloseAll:
  196.     Move.l    #0,d7
  197.     Move.l    StackPointer(a5),a7
  198. CloseW2:
  199.     Move.l    MappedWindowAddress(a5),a0
  200.     Call      CloseWindow,intuition
  201. CloseW1:
  202. .Loop:
  203.     Move.l    PictWindowUserPort(a5),a0
  204.     Call      GT_GetIMsg,gadtools
  205.     Move.l    d0,a3
  206.     Tst.l     a3
  207.     Beq       .EndLoop
  208.     Move.l    (a3),d0
  209.     Move.l    a3,a1
  210.     Call      GT_ReplyIMsg,gadtools
  211.     Bra       .Loop
  212. .EndLoop:
  213.     Move.l    PictWindowAddress(a5),a0
  214.     Call      CloseWindow,intuition
  215. CloseScreen:
  216.     Move.l    ScreenAddress(a5),a0
  217.     Call      CloseScreen
  218. UnAllocMem:
  219.     Move.l    a5,a1
  220.     Call      FreeVec,exec
  221. CloseLibs:
  222.     CloseLib  intuition
  223.     CloseLib  gadtools
  224.     CloseLib  dos
  225. End:
  226.     Move.l    d7,d0
  227.     Rts
  228. ;fe
  229. ;fs " Errors"
  230. LibError:
  231.     Move.l    #10,d7
  232.     Bra       End
  233.  
  234. Win1Error:
  235.     Move.l    #11,d7
  236.     Bra       UnAllocMem
  237.  
  238. Win2Error:
  239.     Move.l    #12,d7
  240.     Bra       CloseW1
  241.  
  242. MemError:
  243.     Move.l    #13,d7
  244.     Bra       CloseLibs
  245. ;fe
  246. ;fs "_MapWindow"
  247. _MapWindow:
  248.     Move.l    #MaxY,d3
  249.     Move.l    PictRastPort(a5),a1
  250.     Move.l    graphics_base,a6
  251. .YLoop:
  252. ;          bsr       Main
  253.     Move.l    #0,d2
  254.     bsr       _CalcY
  255.     bsr       _CalcBase
  256.     bsr       _CalcInc
  257.     Fmove.l   fp4,fp1
  258. ;          Fmod.l    #MaxX,fp1
  259.     fabs
  260.  
  261. .XLoop:
  262.     Move.l    PictRastPort(a5),a1
  263.     Fmod.x    #MaxX,fp1
  264.     Fmove.l   fp1,d0
  265.     Move.l    Y(a5),d1
  266. ;          Move.l    d3,d1
  267.     Call      ReadPixel
  268. ;          Cmp.l     #-1,d0
  269. ;          Beq       .End
  270.     Move.l    MappedRastPort(a5),a1
  271.     Call      SetAPen
  272.     Move.l    d3,d1
  273.     Move.l    d2,d0
  274.     Call      WritePixel
  275. ;          Tst.l     d0
  276. ;          Bne       .End
  277.     Fadd.x    fp3,fp1
  278.     Addq.l    #1,d2
  279.     cmp.l     #MaxX-1,d2
  280.     Bne       .XLoop
  281.     Sub.l     #1,d3
  282.     cmp.l     1,d3
  283.     Bne       .YLoop
  284. .End:
  285.     Rts
  286. ;fe
  287. ;fs "_CalcY"
  288. _CalcY:                 ;d3=Yb -> d3=Yb Y(a5)=Ya
  289.     FMove.l   d3,fp3
  290.     FMove.x   #K,fp0
  291.     Fadd.x    #MaxY,fp0
  292.     Fmul.x    fp3,fp0
  293.     Fsub.x    #MaxY2,fp0
  294.     Fmove.x   #K,fp1
  295.     Fsub.x    #MaxY,fp1
  296.     FAdd.x    fp3,fp1
  297.     Fdiv.x    fp1,fp0
  298.     Fmove.l   fp0,d0
  299.     Move.l    d0,Y(a5)
  300.     Rts
  301. ;fe
  302. ;fs "_CalcBase"
  303. _CalcBase:                              ;d3=Yb ->d3=Yb fp4=Base
  304.     FMove.l   d3,fp3
  305.     FMove.x   #MaxY,fp0
  306.     FSub.x    fp3,fp0
  307.     FAdd.x    #K,fp0
  308.     FMove.x   #MaxX,fp2
  309.     Fdiv.x    #2,fp2
  310.     Fneg.x    fp2
  311.     FMul.x    fp2,fp0
  312.     FMove.x   #K,fp2
  313.     Fdiv.x    fp2,fp0
  314.     Fmove.x   #MaxX,fp1
  315.     Fdiv.x    #2,fp1
  316.     Fadd.x    fp1,fp0
  317.     FMove.x   fp0,fp4
  318.     Rts
  319. ;fe
  320. ;fs "_CalcInc"
  321. _CalcInc:                     ;d3=Yb -> d3=Yb fp3=Inc
  322.     FMove.l   d3,fp3
  323.     fMove.x   #MaxY,fp0
  324.     FSub.x    fp3,fp0
  325.     FAdd.x    #K,fp0
  326.     FMove.x   #K,fp2
  327.     Fdiv.x    fp2,fp0
  328.     FMove.x   fp0,fp3
  329.     Rts
  330. ;fe
  331. ;fs "_FillWin1"
  332. _FillWin1:
  333.     Move.l    #MaxY,d3
  334.     Move.l    PictRastPort(a5),a1
  335.     Move.l    #32,d0
  336.     Call      SetAPen,graphics
  337. .LoopY:
  338.     Move.l    PictRastPort(a5),a1
  339.     Move.l    #0,d0
  340.     Move.l    d3,d1
  341.     Call      Move
  342.     Move.l    #MaxX,d0
  343.     Move.l    d3,d1
  344.     Move.l    PictRastPort(a5),a1
  345.     Call      Draw
  346.     Sub.l     #8,d3
  347.     Bne       .LoopY
  348.     Move.l    #512,d3
  349. .LoopX:
  350.     Move.l    PictRastPort(a5),a1
  351.     Move.l    #0,d1
  352.     Move.l    d3,d0
  353.     Call      Move
  354.     Move.l    #MaxY,d1
  355.     Move.l    d3,d0
  356.     Move.l    PictRastPort(a5),a1
  357.     Call      Draw
  358.     Sub.l     #8,d3
  359.     Bne      .LoopX
  360.     Rts
  361. ;fe
  362. ;fe
  363. ;fs "Datas"
  364. ;fs " Windows Definition"
  365. ;fs "  PictWindow"
  366. PictWindowTagList:
  367.     Dc.l      WA_Width,MaxX+1
  368.     Dc.l      WA_Height,MaxY+1
  369.     Dc.l      WA_Left,20
  370.     Dc.l      WA_Top,20
  371.     Dc.l      WA_Title,PictWindowTitle
  372. ;          Dc.l      WA_CustomScreen
  373. ;Win1Scr:  Dc.l      0
  374.     Dc.l      WA_ScreenTitle,ScreenTitle
  375.     Dc.l      WA_CloseGadget,TRUE
  376.     Dc.l      WA_Activate,TRUE
  377.     Dc.l      WA_DragBar,TRUE
  378.     Dc.l      WA_SizeGadget,FALSE
  379.     Dc.l      WA_DepthGadget,TRUE
  380.     Dc.l      WA_IDCMP,IDCMP_CLOSEWINDOW|IDCMP_REFRESHWINDOW|IDCMP_RAWKEY
  381.     Dc.l      TAG_DONE
  382.  
  383. PictWindowTitle:
  384.     Dc.b      "Picture to be mapped ...",0
  385.     Even
  386.  
  387. ScreenTitle:
  388.     Dc.b      "Kaliosys Quantrum Ground Mapper v0.1 by TROLL",0
  389.     Even
  390. ;fe
  391. ;fs "  MappedWindow"
  392. MappedWindowTagList:
  393.     Dc.l      WA_Width,MaxX+1
  394.     Dc.l      WA_Height,MaxY+1
  395.     Dc.l      WA_Left,300
  396.     Dc.l      WA_Top,20
  397.     Dc.l      WA_Title,MappedWindowTitle
  398.     Dc.l      WA_ScreenTitle,ScreenTitle
  399.     Dc.l      WA_CustomScreen
  400. ;Win2Scr:  Dc.l      0
  401. ;          Dc.l      WA_CloseGadget,FALSE
  402.     Dc.l      WA_Activate,TRUE
  403.     Dc.l      WA_DragBar,TRUE
  404.     Dc.l      WA_SizeGadget,FALSE
  405.     Dc.l      WA_DepthGadget,TRUE
  406.     Dc.l      TAG_DONE
  407.  
  408. MappedWindowTitle:
  409.     Dc.b      "Mapped Picture ...",0
  410.     Even
  411. ;fe
  412. ;fe
  413. ;fs " Screen Definition"
  414. ScreenTagList:
  415.     Dc.l      SA_LikeWorkbench,TRUE
  416.     Dc.l      SA_ShowTitle,TRUE
  417.     Dc.l      0
  418.  
  419. MainScreenTitle:
  420.     Dc.b      "Exemple Pour Seb v0.1",0
  421. ;fe
  422. ;fs " Junk"
  423. ;fe
  424. ;fe
  425.